*===================================================================*
*																	*
*                    Shaping Electoral Outcomes :                   *
*   Intra and Anti-systemic Violence in Indian Assembly Elections   *
*      	   Imke Harbers, Cécile Richetta, Enrike van Wingerden      *
*																	*
*===================================================================*

*===================================================================*
* 					REPLICATION FILE 2 : MAIN TABLES				*
*===================================================================*

* IF NECESSARY: INSTALL PACKAGES 
* ssc install estout
* ssc install collin

global dir "C:/setpath" 
use "$dir/data.dta"

* TABLES IN THE MAIN TEXT
* Table 1
	xtset SHF_AC_ID Sequence
	* Model 1 
	xtreg Turnout_Percentage i.Count2PIl i.state_ac_align ///
	Margin_Percentage lit ele urb Turnout_lag WIDisCount2PIntr, ///
	fe vce(cluster ECI_DT_NAME)
	eststo A
	* Model 2
	xtreg Turnout_Percentage i.Count3Vl i.state_ac_align ///
	Margin_Percentage lit ele urb Turnout_lag, ///
	fe vce(cluster ECI_DT_NAME)
	eststo B
	* Model 3
	xtreg Turnout_Percentage i.Count2PIl i.Count3Vl i.state_ac_align ///
	Margin_Percentage lit ele urb Turnout_lag WIDisCount2PIntr, ///
	fe vce(cluster ECI_DT_NAME)
	eststo C
	* Check multicollinearity --> all VIF below 3
	collin Count2PIl Count3Vl state_ac_align ///
	Margin_Percentage lit ele urb Turnout_lag WIDisCount2PIntr
	* Export full table 
	esttab A B C ///
	using "$dir/maintable1.rtf", /// 
	star(* 0.05 ** 0.01 *** 0.001) ///
	title("Table 1. Results Fixed Effects Analysis, Dependent Variable: Turnout (%)") ///
	se scalars(ll) obslast ///
	replace
	est drop *

* Table 2
	* Model 1 
	zip Count2PIntr i.state_ac_align Margin_Percentage lit ele ///
	urb rugg_std i.Constituency_Type i.State_Name, inflate(SHF_AC_ID) ///
	vce(robust)
	eststo A
	* Model 2
	zip Count3 i.state_ac_align Margin_Percentage lit ele ///
	urb rugg_std i.Constituency_Type i.State_Name, inflate(SHF_AC_ID) ///
	vce(robust)
	eststo B
	* Check multicollinearity --> all VIF below 3
	collin Count2PIntr Count3 state_ac_align ///
	Margin_Percentage lit ele urb rugg_std Constituency_Type
	* Export full table 
	esttab A B ///
	using "$dir/maintable2.rtf", /// 
	star(* 0.05 ** 0.01 *** 0.001) ///
	title("Table 2. Results Zero-Inflated Poisson (ZIP) Regression, Logit Inflation Model") ///
	se scalars(ll N_zero k ic) obslast ///
	replace
	est drop *

* Table 3
	* Model 1
	xtreg incumb_vote_shr i.Count2PIntr i.state_ac_align ///
	Margin_Percentage lit ele urb Turnout_Percentage ///
	incumb_vote_lag, fe vce(cluster ECI_DT_NAME)
	eststo A
	* Model 2
	xtreg incumb_vote_shr i.Count2PIntr##i.state_ac_align ///
	Margin_Percentage lit ele urb Turnout_Percentage ///
	incumb_vote_lag, fe vce(cluster ECI_DT_NAME)
	eststo B
	* Check multicollinearity --> all VIF below 3
	collin Count2PIntr state_ac_align ///
	Margin_Percentage lit ele urb Turnout_Percentage incumb_vote_lag
	* Export full table 
	esttab A B ///
	using "$dir/maintable3.rtf", /// 
	star(* 0.05 ** 0.01 *** 0.001) ///
	title("Table 3. Results Fixed Effects Analysis, Dependent Variable: Incumbent Vote Share (%)") ///
	se scalars(ll) obslast ///
	replace


